﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using FluentValidation;
using AutoFacUtils;
using CashFlow.ShopManage.Models.User;
using CashFlow.ShopManage.Service;

namespace CashFlow.ShopManage.Validator
{
    public class UpdateUserReferenceInviationCodeModelValidator
        : AbstractValidator<UpdateUserReferenceInviationCodeModel>
    {
        private IUserService GetUserService() { return AutoFacHelper.Get<IUserService>(); }

        public UpdateUserReferenceInviationCodeModelValidator()
        {
            RuleFor(x => x.UserId).Must(x => ValidatorTool.IsUserBelongsMyShop(x))
                .WithMessage("非法UserId");
            RuleFor(x => x.ReferenceInvitationCode)
                .Must((item, code) => ValidatorTool.IsValidInvitationCodeInShop2(item.UserId, code))
                .WithMessage("非法InvitationCode");
        }
    }
}